package com.dkd.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dkd.client.entity.VendingMachineEntity;
import com.dkd.client.vm.VmClient;
import com.dkd.config.constant.TaskType;
import com.dkd.dao.TaskDao;
import com.dkd.entity.TaskEntity;
import com.dkd.service.TaskService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.dkd.client.entity.RepairCountDto;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

@Service
@RequiredArgsConstructor
@Slf4j
public class TaskServiceImpl extends ServiceImpl<TaskDao, TaskEntity> implements TaskService {
    private final VmClient vmClinet;
    @Override
    public Integer getRepairCount(String innerCode, LocalDate start, LocalDate end, RepairCountDto repairCountDto) {
        //判断信息是否存在在

        return this.lambdaQuery()
                .eq(TaskEntity::getInnerCode, innerCode)
                .eq(TaskEntity::getTaskStatus, TaskType.TASK_TYPE_REPAIR)
                .between(TaskEntity::getCreateTime, start, end)
                .count();
    }

    @Override
    public Integer getSupplyCount(String innerCode, LocalDate start, LocalDate end, RepairCountDto repairCountDto) {

        return this.lambdaQuery()
                .eq(TaskEntity::getInnerCode, innerCode)
                .eq(TaskEntity::getTaskStatus,TaskType.TASK_TYPE_SUPPLY)
                .between(TaskEntity::getCreateTime, start, end
                ).count();
    }
}
